/**
 * Created by zqk on 2019/2/19.
 */
$(document).ready(function () {
    console.log(notices);
    var k = 0;
    if (notices[k]) {
        $('.title').html(notices[k]['sTitle']);
        $('.time').html(notices[k]['tTime']);
        $('.mContent').html(notices[k]['mContent']);
        if (notices[k]['mFooter']) {
            $('#footer').show();
            $('#footer').html(notices[k]['mFooter']);
            $('#iNoId').val(notices[k]['iNoId']);
        }
        xhExtra.ajaxRequest('msg/setMsgRead', {
                iNoId: notices[k]['iNoId'],
            }
            );
        $('#prevOne', parent.document).attr('disabled',true);
        if (notices.length==1) {
            $('#nextOne', parent.document).attr('disabled',true);
        }
    }

    $('#nextOne', parent.document).click(function () {
        k = k + 1;
        if (notices[k]) {
            $('.title').html(notices[k]['sTitle']);
            $('.time').html(notices[k]['tTime']);
            $('.mContent').html(notices[k]['mContent']);
            if (notices[k]['mFooter']) {
                $('#footer').show();
                $('#footer').html(notices[k]['mFooter']);
                $('#iNoId').val(notices[k]['iNoId']);
            }
            xhExtra.ajaxRequest('msg/setMsgRead', {
                    iNoId: notices[k]['iNoId'],
                }
            );
        }
        if (k + 1 == notices.length) {
            $('#nextOne', parent.document).attr('disabled',true);
        }
        if (k >=1) {
            $('#prevOne', parent.document).attr('disabled',false);
        }
    });
    $('#prevOne', parent.document).click(function () {
        k = k - 1;
        if (notices[k]) {
            $('.title').html(notices[k]['sTitle']);
            $('.time').html(notices[k]['tTime']);
            $('.mContent').html(notices[k]['mContent']);
            if (notices[k]['mFooter']) {
                $('#footer').show();
                $('#footer').html(notices[k]['mFooter']);
                $('#iNoId').val(notices[k]['iNoId']);
            }
            xhExtra.ajaxRequest('msg/setMsgRead', {
                    iNoId: notices[k]['iNoId'],
                }
            );
        }
        if (k == 0) {
            $('#prevOne', parent.document).attr('disabled',true);
        }
        if (k == 0 && notices.length>1) {
            $('#nextOne', parent.document).attr('disabled',false);
        }
    });
});
